<template>
	
		<view >
		
			
			<block v-for="(item, index) in villageCitys" :key="index">
				<block >
					<view class="list-cell u-border-bottom" @tap="getCity(item)">
							{{item.name}}
					</view>
				</block>
			</block>
		</view>
		
		
		<!-- <rf-back-top :scrollTop="scrollTop"></rf-back-top> -->
		<!-- <rf-back-home></rf-back-home> -->
	
</template>

<script>
import { provincesCitys } from '@/api/basic';

export default {
	data() {
		return {
			loading: true,
			scrollTop: 0,
			
			villageCitys: [],
		};
	},
	onLoad() {
		this.villageCitys = uni.getStorageSync('villageCitys');
		//console.log(this.villageCitys)
		if (this.villageCitys) {
			this.loading = false;
		} else {
			this.initData();
		}
	},
	onShow() {

	},
	onPageScroll(e) {
		this.scrollTop = e.scrollTop;
	},
	mounted() {
		
	},
	computed: {
		
	},
	methods: {
		navTo(route) {
			this.$mRouter.push({ route });
		},
		getCity(item) {
			uni.setStorageSync('villageCity', item);
			return uni.reLaunch({
				url:'../index/index'
			})
			//this.$mRouter.back();
		},
		async initData() {
			await this.getProvincesCitys();
		},
		async getProvincesCitys() {
			await this.$http.get(`${provincesCitys}`).then(async r => {
				this.loading = false;
				let items = r;
				console.log(r)
				
				
				this.villageCitys = items;
				uni.setStorageSync('villageCitys', items);
				
			}).catch(err => {
				this.loading = false;
			});
		},
	}
};
</script>

<style lang="scss">
page {
	background: #F5F5F5;
	.list-cell {
		width: 100%;
		line-height: 24px;
		background: #FFF;
		color: #323233;
		font-size: 14px;
		display: flex;
		justify-content: left;
		box-sizing: border-box;
		padding: 10px 24rpx;
		overflow: hidden;
		text-align: left;
	}
}
</style>
